/* 
 * 	This file is part of VPN Monitor Project 7..

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package monitor.gui;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.util.EnumMap;

import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;

import monitor.gui.GuiControl.SettingsEnum;

@SuppressWarnings("serial")
class About extends JPanel implements ColorObserver {
	private JTextArea textArea = null;
	
	About(GuiControl control, EnumMap<SettingsEnum, String> settings){
		control.addColorObserver(this);
		createPanel(settings);
	}
	
	@Override
	public void colorUpdated(SettingsEnum type, Color color) {
		if(type==SettingsEnum.COLOR_FOREGROUND)
			textArea.setForeground(color);
		else if(type==SettingsEnum.COLOR_BACKGROUND)
			this.setBackground(color);
	}
	
	private void createPanel(EnumMap<SettingsEnum, String> settings){
		this.setBackground(SettingsEnum.color(settings.get(SettingsEnum.COLOR_BACKGROUND)));
		this.setLayout(new BorderLayout());
		this.setPreferredSize(new Dimension(500,100));
		textArea = new JTextArea();
		textArea.setForeground(SettingsEnum.color(settings.get(SettingsEnum.COLOR_FOREGROUND)));
		textArea.setWrapStyleWord(true);
		textArea.setLineWrap(true);
		textArea.setEditable(false);
		textArea.setOpaque(false);
		textArea.append("VPN Monitor Project 7\n");
		textArea.append("This program is released under GNU GPLv3, this application are intended to work " +
				"under the linux based operation system Ubuntu.\n");
		textArea.append("\nLICENCE\n");
		for(String s : LICENCE)
			textArea.append(s);
		JScrollPane scrollPane = new JScrollPane(textArea);
		scrollPane.setOpaque(false);
		scrollPane.getViewport().setOpaque(false);
		this.add(scrollPane, BorderLayout.CENTER);
	}

	
	private static final String[] LICENCE = {
		"This program is free software: you can redistribute it and/or modify\n",
		"it under the terms of the GNU General Public License as published by\n",
		"the Free Software Foundation, either version 3 of the License, or\n",
		"(at your option) any later version.\n",
		"\n",
		"This program is distributed in the hope that it will be useful,\n",
		"but WITHOUT ANY WARRANTY; without even the implied warranty of\n",
		"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n",
		"GNU General Public License for more details.\n",
		"\n",
		"You should have received a copy of the GNU General Public License\n",
		"along with this program.  If not, see <http://www.gnu.org/licenses/>."
	};
}
